<?php
if (!defined('BASEPATH'))
	exit ('No direct script access allowed');

class About extends CI_Controller {
	var $data;
	function __construct() {
		parent :: __construct();
		if ($this->session->userdata('userid') == FALSE) {
			Header("Location:" . site_url('welcome'));
			exit ();
		}
		$this->data['username'] = $this->session->userdata('username');
		parse_str($_SERVER['QUERY_STRING'], $_GET);
		$this->types = isset ($_GET['types']) ? $_GET['types'] : '1';

	}
	function index() {

		$this->load->library('ckeditor');
		$this->load->library('ckFinder');
		$this->ckeditor = new CKEditor();
		$this->ckeditor->basePath = '/js/ckeditor/';
		$this->ckeditor->config['toolbar'] = 'Full';
		$this->ckeditor->config['language'] = 'zh-cn'; // $this -> ckeditor -> config[''] 添加一些你需要的配置详细参数自己查一下
		CKFinder :: SetupCKEditor($this->ckeditor, '/js/ckfinder/');
		$this->load->model('infos');
		$info = $this->infos->select_info($this->types);
		$this->data['content'] = $info->content;
//		$this->data['class_id'] = $info->class_id;
		$this->data['types'] = $this->types;
		$this->load->view('admin/about', $this->data);
	}
	function updates() {
		//echo $this->types;
		if (isset ($_POST['mailtpl_content'])) {
			$this->data['mailtpl_content'] = $_POST['mailtpl_content'];
			$this->load->model('infos');
			$this->infos->update_info('info', 'content', $this->data['mailtpl_content'], $this->types);
			$this->message['message_info'] = '企业信息更新成功！';
			$this->message['message_url'] = site_url('admin/about?types='.$this->types);
			$this->load->view('admin/message',$this->message);
		} else {
			$this->load->view('welcome', $this->data);
		}
	}
}